import { defineStore } from "pinia";

export const useUserState = defineStore("userInfo", {
  state: () => {
    return {
      userInfo: {
        userName: "张三",
        userId: 1,
        isAdmin: false,
      },
      token: "",
    };
  },
  actions: {
    setUserInfo(userInfo) {
      this.userInfo = userInfo;
    },
    setToken(token) {
      this.token = token;
    },
  },
  getters: {
    getUserInfo() {
      return this.userInfo;
    },
    getToken() {
      return this.token;
    },
  },
});
